package com.leyou.item.mapper;

import com.leyou.item.entity.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.additional.idlist.IdListMapper;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.Date;

public interface SkuMapper extends Mapper<Sku>, InsertListMapper<Sku>, IdListMapper<Sku, Long> {
    @Update("update tb_sku set enable = #{saleable} , update_time = #{updateTime} where spu_id = #{spuId}")
    void updateSaleable(@Param("spuId") Long id, @Param("saleable") Boolean saleable, @Param("updateTime")Date updateTime);

    @Update("update tb_sku set stock = stock - #{num} where id = #{id}")
    int deductStock(@Param("id") Long id, @Param("num") Integer num);
}
